home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / comm / net / tf02.lha / TinyFugue / tf-lib / kbstack.tf < prev    next >
Text File  |  1995-08-12  |  950b  |  33 lines

  1. ;;;; Keyboard stack
  2. ;;;; This is useful when you're in the middle of typing a long line,
  3. ;;;; and want to execute another command without losing the current line.
  4. ;;;; Type ESC DOWN to save the current input line on a stack.
  5. ;;;; Type ESC UP to restore the saved line.  Any number of lines can
  6. ;;;; be saved and restored.
  7.  
  8. /~loaded kbstack.tf
  9.  
  10. /def -ib^[^[OB = /kb_push
  11. /def -ib^[^[[B = /kb_push
  12. /def -ib^[^[OA = /kb_pop
  13. /def -ib^[^[[A = /kb_pop
  14.  
  15. /def -i kb_push = \
  16.     /let line=$(/recall -i 1)%;\
  17.     /if ( line !~ "" ) \
  18.         /set _kb_stack_top=$[_kb_stack_top + 1]%;\
  19.         /set _kb_stack_%{_kb_stack_top}=%{line}%;\
  20.     /endif%;\
  21.     /dokey dline
  22.  
  23. /def -i kb_pop = \
  24.     /if ( _kb_stack_top > 0 ) \
  25.         /dokey dline%;\
  26.         /test input(_kb_stack_%{_kb_stack_top})%;\
  27.         /unset _kb_stack_%{_kb_stack_top}%;\
  28.         /set _kb_stack_top=$[_kb_stack_top - 1]%;\
  29.     /else \
  30.         /echo %% Keyboard stack is empty.%;\
  31.     /endif
  32.  
  33.